<?php
/**
 * Created by PhpStorm.
 * User: changshuiwang
 * Date: 2016/7/22
 * Time: 13:23
 */
namespace common\service;
use common\models\Common;
use Yii;
use yii\web\User;

class UserSrv extends BaseSrv
{
    private $_info;
    public function __construct()
    {
        parent::__construct();
        return $this->init();
    }

    public function init()
    {
        $this->_info=$this->getUserInfo();
    }

    //从cookie中获取信息
    public function getUserInfo()
    {

        if(isset($_COOKIE['cookie_auth'])){
            $result=json_decode(Common::authcode($_COOKIE['cookie_auth'],'DECODE'),'true');
            return $result;
        }
        //var_dump($result);die;
    }

    public function getUserId()
    {
        return $this->_info['_userid'];
    }

    public function getUsername()
    {
        return $this->_info['_username'];
    }

    public function getUserIp()
    {
        return $this->_info['_userip'];
    }
}